home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 15375 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: newsfeed.concentric.net!news
  2. From: "Alan L. Lovejoy" <alovejoy@concentric.net>
  3. Newsgroups: comp.lang.java,comp.lang.c++,comp.lang.smalltalk
  4. Subject: Re: Will Java kill C++?
  5. Date: Thu, 04 Apr 1996 18:42:21 -0800
  6. Organization: Modulation
  7. Message-ID: <3164888D.2B01@concentric.net>
  8. References: <3134D499.653E@ix.netcom.com> <313613B2.136E@ksopk.sprint.com> <4i7qhl$ik6@cronkite.seas.gwu.edu> <4iuhi7$fmf@sundog.tiac.net> <4iumap$mn5@hustle.rahul.net> <31582A45.3742@vmark.com> <3163C031.4FB1@esec.ch>
  9. NNTP-Posting-Host: cnc009041.concentric.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  14.  
  15. Oliver Plohmann wrote:
  16. > Jeff Sutherland wrote:
  17. > > There is a benchmark in this month's Smalltalk Report showing how a Smalltalk
  18. > > application can be tuned to run *faster* than C.
  19. > In Smalltalk all methods are bound dynamically. No way method invocation can ever be
  20. > faster as function invocation in C with function addresses determined at compile time.
  21. > With some people you just can't argue that Smalltalk is slow.
  22.  
  23.  
  24. Bzzzt!  Not according to the benchmarks I've done.  Go benchmark the factorial or fibonacci 
  25. functions (implemented recursively) in both C and a good Smalltalk.  You are in for a big
  26. surprise.  The problem is NOT that message sends are slower than function calls, but rather
  27. that you have to do almost everything by sending a message.
  28.  
  29. The reasons that a C program may be faster than a Smalltalk program would be:
  30.  
  31. 1) Numeric values can be manipulated more efficiently, both because there are neither
  32. any function nor message sends required, and because the CPU is designed to optimize
  33. the value-oriented representation of numeric values (the latter could be addressed
  34. with different CPU design).
  35.  
  36. 2) Much processing/data twiddling can be done by direct access into array and
  37. structure internals without the necessity of calling functions or sending messages.
  38.  
  39. 3) The compiler can perform many optimizations that rely on the fact that values 
  40. are not encapsulated and that functions can be bound by static analysis of the
  41. program text.
  42.  
  43. 4) Smalltalk (and Java) objects are always stored on the heap, and are always
  44. accessed by at least one level of indirection (except for SmallInteger and
  45. Character, in the case of Smalltalk.
  46.  
  47. --Alan
  48.